<?php
class Sizevalue extends AppModel {
	var $name = 'Sizevalue';
	var $hasMany = array(
		'ProductSize' => array(
			'className' => 'ProductSize',
			'foreignKey' => 'sizevalue_id',
			'dependent' => true		
		),
		'Product' => array(
			'className' => 'Product',
			'foreignKey' => 'product_id',
			'dependent' => true		
		)
	);
	var $validate = array(
		'size_value' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'Size value cannot be left empty',
			),
		)
	);

  function size_menu(){
      $this->unbindModel(array('hasMany'=>'Product'));
      $allsizes=$this->find('all',array('order'=>'Sizevalue.size_value  asc','group'=>'Sizevalue.size_value'));

    pr($allsizes);
    $i=0;
//    foreach($allsizes as  $allsizevalue){
//       echo "<br>".$sizeproductcount=$this->ProductSize->find('count',array('conditions'=>array('ProductSize.sizevalue_id'=>$allsizevalue['Sizevalue']['id']),'recursive'=>'-1'));
//        if($sizeproductcount>0){
//        $sizemenu[$i]=$allsizevalue['Sizevalue']['id'].'@'.$allsizevalue['Sizevalue']['size_value'];
//        $i++;
//    }
//  }
  //pr($sizemenu);
    //return $sizemenu;
}

}
?>